type throttleStruct = (func: Function, interval: number) => Function

const throttle:throttleStruct = (func, interval) => {
  let timer: object | null = null;
  return (...arg: any) => {
    if (!timer) {
      timer = setTimeout(():void => {
        func(...arg);
        timer = null;
      }, interval);
    }
  };
}

export default throttle